﻿using System;
using System.Windows.Data;

namespace Ags.MonsterTools.PingTool
{
    class IpAddressConverter : IValueConverter
    {
        private const string ZeroIp = "0.0.0.0";

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var result = value as PingResult;
            if (result == null)
                return Binding.DoNothing;

            if (result.Result.Address.ToString() == ZeroIp)
            {
                return result.PingTarget.ToString();
            }
            return result.Result.Address;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return Binding.DoNothing;
        }
    }
}
